package com.loong.common.exception;


import com.loong.common.enumerate.ResultCode;

/**
 * 自定义全局异常
 */
public class GlobalException extends RuntimeException {

	private int code;
	private String extraMessage;

	public GlobalException(ResultCode resultCode) {
		super(resultCode.getMessage());
		this.code = resultCode.getCode();
		this.extraMessage = resultCode.getMessage();
	}

	public GlobalException(Throwable cause) {
		super(cause);
	}

	public GlobalException(String message, Throwable cause) {
		super(message, cause);
	}

	public GlobalException(int code, String message, String extraMessage, Throwable cause) {
		super(message, cause);
		this.code = code;
		this.extraMessage = extraMessage;
	}

	public GlobalException(ResultCode resultCode, String extraMessage) {
		this(resultCode.getCode(), resultCode.getMessage(), extraMessage, null);
	}

	public GlobalException(String extraMessage) {
		this(ResultCode.SERVER_ERROR, extraMessage);
	}

	public int getCode() {
		return code;
	}

	public String getExtraMessage() {
		return extraMessage;
	}

}
